package models

import (
	"gorm.io/gorm"
	"pro/global"
)

// 内容表
type Videos struct {
	gorm.Model
	Title      string
	AuthorId   int
	Image      string //图片
	Status     int    // 0-待审核, 1-通过, 2-不通过
	Hot        int    //热度
	Visibility int    // 权限 1-全部可见 2-粉丝可见 3-尽自己可见
	Types      string //推送类型
	Follow     int    //是否关注 0-未关注 2-已关注
}

func (v *Videos) AddVideo() error {
	return global.DB.Create(&v).Error
}

func (v *Videos) GetVideoById(id int64) error {
	return global.DB.Where("id=?", id).Find(&v).Error
}

// 关注表
type FollowLog struct {
	gorm.Model
	UserId int
	DistId int
}

func (f *FollowLog) CreateFl() error {
	return global.DB.Create(&f).Error
}

// 点赞记录表
type LikesLog struct {
	gorm.Model
	UserId  int
	VideoId int
}

func (ll *LikesLog) CreateLl() error {
	return global.DB.Create(&ll).Error
}

func (ll *LikesLog) GetLlById(userId, videoId int) error {
	return global.DB.Where("user_id=? AND video_id=?", userId, videoId).Error
}

func (ll *LikesLog) DelLL(userId, videoId int64) error {
	return global.DB.Where("user_id=? AND video_id=?", userId, videoId).
		Delete(&ll).Error
}

type CommentLog struct {
	gorm.Model
	UserId  int    //用户ID
	VideoId int    //帖子ID
	Comment string //评论内容
}

func (cl *CommentLog) CreateCl() error {
	return global.DB.Create(&cl).Error
}
